cmake_minimum_required(VERSION 3.5.1)
project(GE_IR[CXX])

set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE)

if (DEFINED ENV{ASCEND_INSTALL_PATH})
    set(ASCEND_PATH $ENV{ASCEND_INSTALL_PATH})
else ()
    set(ASCEND_PATH /usr/local/Ascend)
endif()

set(ATC_INCLUDE_DIR ${ASCEND_PATH}/compiler/include)

set(SRC_LIST
    "src/main.cpp"
	"src/graph_utils.cpp"
	"src/graph_utils.h"
)

set(common_compile_options
    -std=c++11
    -g
    -Wall    
)

set(common_compile_definitions
    _GLIBCXX_USE_CXX11_ABI=0	
)

############ graph_run ############
add_executable(graph_run
    ${SRC_LIST}
)

target_compile_options(graph_run PRIVATE
    ${common_compile_options}
)

target_compile_definitions(graph_run PRIVATE
    ${common_compile_definitions}	
)

target_include_directories(graph_run PRIVATE
    ${ASCEND_PATH}/opp/built-in/op_proto/inc
    ${ATC_INCLUDE_DIR}/graph
    ${ATC_INCLUDE_DIR}/ge
    ${ATC_INCLUDE_DIR}
)

target_link_directories(graph_run PRIVATE
    ${ASCEND_PATH}/compiler/lib64/stub	
)

target_link_libraries(graph_run PRIVATE
    -Wl,--no-as-needed
    graph
    ge_runner
    -Wl,--as-needed    
)

############ install ############
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_LIST_DIR})

install(TARGETS graph_run OPTIONAL
    RUNTIME DESTINATION output	
)
